<template>
    <view class="index">
        <u-sticky>
            <view class="search">
                <view class="fiexd">
                    <u-search placeholder="请输入商品名称" v-model="queryObj.bt" :animation="false" :clearabled="true" @clear="clear" @search="search" @custom="search"></u-search>
                </view>
            </view>
        </u-sticky>
        <s-goods :goodsList="list"></s-goods>
        <!-- 授权弹窗 -->
        <s-auth-modal />
    </view>
</template>

<script>
import {getInformationListApi} from "@/sheep/api";
import {myMixins} from "@/mixins/myMixins";

export default {
    mixins:[myMixins],
    data() {
        return {
            type:'',
            keyword: "",
            list:[]
        };
    },
    onLoad(options) {
        this.type=options.type
    },
    onShow(options) {
        this.queryObj.city = uni.getStorageSync('city')
    },
    // 下拉刷新
    onPullDownRefresh() {
        this.list=[]
        this.queryObj.pageNum=1
        this.getList();
    },
    methods: {
        getList(){
            if (this.queryObj.twoType=='全部'){
                this.queryObj.twoType=''
            }
            getInformationListApi(this.queryObj).then(res=>{
                this.list = this.list.concat(res.rows)
                this.total = res.total
                if (this.queryObj.pageNum*this.queryObj.pageSize<this.total){
                    this.status = 'loadmore'
                }else{
                    this.status = 'nomore'
                }
                uni.stopPullDownRefresh()
            })
        },
        clear() {
            this.queryObj.bt = "";
        },
        search() {
            this.list=[]
            this.queryObj.pageNum=1
            this.getList()
        },
    },
};
</script>

<style lang="scss" scoped>
.index {
    height: 100vh;
    background: #f0f0f0;
    .search {
        height: 90rpx;
        line-height: 90rpx;
        background-color: #fff;
        .fiexd {
            // line-height: 100rpx;
            padding: 0 20rpx;
        }
    }
    //瀑布流
    .load-txt {
        padding: 0 0 20rpx 0;
        text-align: center;
        color: #999;
        font-size: 24rpx;
    }
    .load-icon {
        width: 300rpx;
        height: 300rpx;
        margin: 0 auto 20rpx auto;
        display: block;
    }
}
</style>
